// 用户管理路由 /admin/acl/user
const express = require('express');
const userController = require('../controllers/userController');
const {authMiddleware} = require('../middlewares/authMiddleware');
const {apiPathMiddleware} = require('../middlewares/apiPathMiddleware');

const router = express.Router();

// 创建用户
router.post('/save', authMiddleware, apiPathMiddleware('user/save'), userController.createUser);
// 修改用户
router.put('/update', authMiddleware, apiPathMiddleware('user/update'), userController.updateUser);
// 删除用户
router.delete('/remove/:id', authMiddleware, apiPathMiddleware('user/remove'), userController.removeUser);
// 批量删除
router.delete('/batchRemove', authMiddleware, apiPathMiddleware('user/batchRemove'), userController.batchRemoveUser);
// 某一个用户的已有权限与所有权限
router.get('/toAssign/:id', authMiddleware, userController.toAssign);
// 给用户分配角色
router.post('/doAssignRole', authMiddleware, apiPathMiddleware('user/doAssignRole'), userController.doAssignRole);
// 获取用户列表
router.get('/:page/:limit/', authMiddleware, apiPathMiddleware('user'), userController.getAllUsers);

module.exports = router;
